﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Sunny.UI;

namespace MMS
{
    public partial class Frm_Root : UIForm
    {
        public Frm_Root()
        {
            InitializeComponent();
        }
        public string rootID { get; set; }
        public string storename { get; set; }

        private void Frm_Root_Load(object sender, EventArgs e)
        {
            LoadPage();
            InitFromSize();
            this.Text = "超市会员管理系统(" + storename+")";
        }



        private void InitFromSize()
        {
            //隐藏窗⼝边框
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            //获取屏幕的宽度和⾼度
            int w = System.Windows.Forms.SystemInformation.VirtualScreen.Width;
            int h = System.Windows.Forms.SystemInformation.VirtualScreen.Height - SystemInformation.MenuHeight- SystemInformation.CaptionHeight;
            //设置最⼤尺⼨和最⼩尺⼨（如果没有修改默认值，则不⽤设置）
            this.MaximumSize = new Size(w, h);
            this.MinimumSize = new Size(w, h);
            //设置窗⼝位置
            this.Location = new Point(0, 0);
            //设置窗⼝⼤⼩
            this.Width = w;
            this.Height = h;
            //置顶显⽰
            //this.TopMost = true;
        }

        private void LoadPage()
        {
            Page_AddGoods page_AddGoods = new Page_AddGoods();
            Page_SelectGoods page_SelectGoods = new Page_SelectGoods();
            page_SelectGoods.root = true;
            Page_SelectBill page_SelectBill = new Page_SelectBill();
            Page_UpdataMember page_UpdateMember = new Page_UpdataMember();
            page_UpdateMember.root = true;
            Page_UpdataStaff page_UpdataStaff = new Page_UpdataStaff();
            page_UpdataStaff.storeName = storename;
            Page_UpdataRule page_UpdataRule = new Page_UpdataRule();
            page_UpdataRule.name = storename;
            AddPage(page_SelectGoods);
            AddPage(page_AddGoods);
            AddPage(page_SelectBill);
            AddPage(page_UpdateMember);
            AddPage(page_UpdataStaff);
            AddPage(page_UpdataRule);
            SelectPage(1005);
        }

        private void Frm_Root_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (MessageBox.Show("还有信息未处理,是否确认关闭?", "退出确认", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK)
            {
                //关闭入口程序
                Application.OpenForms[0].Close();
            }
            else
            {
                e.Cancel = true;
            }
        }

        private void Btns_Click(object sender, EventArgs e)
        {
            UIButton btn = (UIButton)sender;

            int index = Convert.ToInt32(btn.TipsText);
            SelectPage(index);
        }
    }
}
